<html>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<head>
		自动添加用户
	</head>
	<script src="<?=base_url()?>javascripts/lib/jquery-1.7.min.js" type="text/javascript" language="JavaScript"></script>
	<script src="<?=base_url()?>javascripts/inc/jquery.timers-1.2.js"></script>
	<script>
        $(function() {
            var nameArr = new Array("北京", "上海", "西安", "成都", "深圳");
            var l = nameArr.length;

            $('body').everyTime('0.5s', 'C', function() {
                Xi();
            }, 0, true);
            function Xi() {
                var ht = $("#showmsg").html();
                var p = nameArr[parseInt(Math.random() * l)] ;
                var uname = getrandom(6);
                var uemail = uname+"@"+uname+".com";
                var mydata = "User_name="+uname+"&User_pass=123456"+"&User_mail="+uemail+"&City="+p;
                //$("#showmsg").html(mydata);
                $.ajax({
					type:'POST',
					url:'<?base_url()?>/sx_reg/',
					data:mydata,
					dataType:'json',
					success:function(i){
						if(i.Msg_error!="0"){
							var mm = "["+p+"]"+uname+"添加失败<br>";
						}else{
						var mm = "["+p+"]"+uname+"添加成功<br>";
						}
						$("#showmsg").html(ht+mm);
						//$("#showmsg").html(ht+i);
					
					}
					
				});
            }
			//http://192.168.1.100:8080/auto_user/?action=auto_user
            /*随机字母数字组合*/
            function getrandom(len) {
                var seed = new Array('abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '0123456789');
                var idx, i;
                var result = '';
                for( i = 0; i < len; i++) {
                    idx = Math.floor(Math.random() * 3);
                    result += seed[idx].substr(Math.floor(Math.random() * (seed[idx].length)), 1);
                }

                return result;
            }

        });

	</script>
	<body>
		<div>
			间隔2秒添加一位新用户
		</div>
		<div id="showmsg" ></div>
	</body>
</html>
